<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    html{
        overflow: hidden;
    }
    body{
        /* border-top: 1px solid transparent; */
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }

    .box {
        width: 300px;
        height: 300px;
        background-color: pink;
        margin: 150px;
        overflow: hidden;
        position: relative;
    }

    .son {
        width: 120px;
        height: 120px;
        background-color: tomato;
        margin: 100px auto;
    }
</style>

<body>
    <div class="box">
        <div class="son"></div>
    </div>
    <script>
        let box = document.querySelector('.box');
        let son = document.querySelector('.son');
        
        console.log(box.offsetTop,box.offsetLeft);
        console.log(son.offsetTop,son.offsetLeft);

        console.log('------------------------');
        console.log(box.offsetWidth);     //包含padding和border
        console.log(box.offsetHeight);    //包含padding和border
    </script>
</body>

</html>